package leetcode.code2379;

public class Solution {
	public int minimumRecolors(String blocks, int k) {
		int ans = 101;
		for (int i = 0, w = 0; i < blocks.length(); i++) {
			w += blocks.charAt(i) == 'W' ? 1 : 0;
			if (i >= k && blocks.charAt(i - k) == 'W') {
				w--;
			}
			if (i >= k - 1) {
				ans = Math.min(ans, w);
			}
		}
		return ans;
	}
}
